Skip to content

[SC 9267] Expose log text interface to pass text for qualitative text sections#339

Merged
AnilSorathiya merged 11 commits intomainfrom
anilsorathiya/sc-9267/use-case-1-expose-log-text-interface-to-pass
Apr 1, 2025
Merged

[SC 9267] Expose log text interface to pass text for qualitative text sections#339
AnilSorathiya merged 11 commits intomainfrom
anilsorathiya/sc-9267/use-case-1-expose-log-text-interface-to-pass

Conversation

@AnilSorathiya
Copy link
Contributor

@AnilSorathiya AnilSorathiya commented Mar 24, 2025

Internal Notes for Reviewers

Expose interface to pass through text content in the VM Library that can populate tests blocks in the model documentation template.

Example:
load markdown file with model limitations

file = open("model_limitations.md", "r")
model_limitations = file.read()
file.close()

vm.log_text(
    content_id="model_limitations",
    text=model_limitations
)
  • This will log data in the db and can be accessible on platform UI for any types of documents.

UX:

readme = open("../README.md", "r").read()
vm.log_text(content_id="my_readme", text=readme)

image

External Release Notes

Expose interface to pass through text content in the VM Library that can populate tests blocks in the model documentation template.

Example:
load markdown file with model limitations

file = open("model_limitations.md", "r")
model_limitations = file.read()
file.close()

vm.log_text(
    content_id="model_limitations",
    text=model_limitations
)
  • This will log data in the db and can be accessible on platform UI for any types of documents.

UX:

readme = open("../README.md", "r").read()
vm.log_text(content_id="my_readme", text=readme)

image

@AnilSorathiya AnilSorathiya added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 24, 2025
Copy link
Contributor

@cachafla cachafla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👏 working well for me.

I'd suggest one final change to improve the UX. Currently a user sees the following since we return the metadata object:

image

I'd suggest we take advantage of the existing components we use to preview results to show the user a preview of the logged HTML. Since the text could be big, we could probably render just an collapsed-by-default accordion component like we do in places like this:

image

When the user successfully calls log_text() it would be good to see a success message and a collapsed accordion where the user can view the preview of the logged contents and check how it's formatted, etc.

@AnilSorathiya
Copy link
Contributor Author

AnilSorathiya commented Mar 31, 2025

Looks good 👏 working well for me.

I'd suggest one final change to improve the UX. Currently a user sees the following since we return the metadata object:

image I'd suggest we take advantage of the existing components we use to preview results to show the user a preview of the logged HTML. Since the text could be big, we could probably render just an collapsed-by-default accordion component like we do in places like this: image When the user successfully calls `log_text()` it would be good to see a success message and a collapsed accordion where the user can view the preview of the logged contents and check how it's formatted, etc.

UX:

readme = open("../README.md", "r").read()
vm.log_text(content_id="my_readme", text=readme)

image

image

@AnilSorathiya AnilSorathiya requested a review from cachafla March 31, 2025 11:41
@validmind validmind locked and limited conversation to collaborators Mar 31, 2025
@validmind validmind unlocked this conversation Mar 31, 2025
@AnilSorathiya AnilSorathiya requested a review from johnwalz97 April 1, 2025 08:40
@github-actions
Copy link
Contributor

github-actions bot commented Apr 1, 2025

PR Summary

This pull request introduces a new function log_text in the validmind/api_client.py module, which allows logging of free-form text to the ValidMind API. The text is converted to HTML with MathML support if it is not already in HTML format. The function returns an ipywidgets.Accordion widget containing the logged text as HTML. This enhancement provides a more flexible way to log textual data with associated metadata.

Additionally, a utility function is_html is added to validmind/utils.py to determine if a given string contains HTML content. This function uses a combination of heuristics, regular expressions, and BeautifulSoup parsing to make a robust determination.

The __init__.py file is updated to include the new log_text function in the module's public API.

Test Suggestions

  • Test log_text with valid content_id and text to ensure it returns an Accordion widget with the correct HTML content.
  • Test log_text with empty content_id and text to verify that it raises a ValueError.
  • Test log_text with non-string content_id and text to ensure it raises a ValueError.
  • Test is_html with a variety of HTML and non-HTML strings to ensure it correctly identifies HTML content.
  • Test is_html with malformed HTML to verify it still returns True if the content is likely HTML.
  • Test is_html with plain text to ensure it returns False.

Copy link
Contributor

@cachafla cachafla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🫡

Copy link
Contributor

@johnwalz97 johnwalz97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice 👏... this is going to be sick!

@AnilSorathiya AnilSorathiya merged commit 2a30c30 into main Apr 1, 2025
6 checks passed
@nrichers nrichers added the highlight Feature to be curated in the release notes label Apr 4, 2025
@johnwalz97 johnwalz97 deleted the anilsorathiya/sc-9267/use-case-1-expose-log-text-interface-to-pass branch August 20, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request highlight Feature to be curated in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants